package com.example.administrator.myweiyue.ui.base;


import android.os.Bundle;
import android.support.annotation.Nullable;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.example.administrator.myweiyue.MyApplication;
import com.example.administrator.myweiyue.ui.component.AppComponent;
import com.trello.rxlifecycle2.LifecycleTransformer;
import com.trello.rxlifecycle2.components.support.RxFragment;

import javax.inject.Inject;

/**
 * Created by Administrator on 2018-01-23.
 */

public abstract  class BaseFragment<T extends BaseContract.BasePresenter> extends RxFragment implements BaseContract.BaseView,IBase{

    protected AppComponent mAppComponent;
    @Nullable
    @Inject
    protected T mPresenter;
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {

        return super.onCreateView(inflater, container, savedInstanceState);
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        mAppComponent = MyApplication.getAppComponent();
Log.e("BaseFragment", String.valueOf(mAppComponent));

    }

    @Override
    public void showLoading() {
//        if (mSimpleMultiStateView != null) {
//            mSimpleMultiStateView.showLoadingView();
//        }
    }

    @Override
    public void showSuccess() {
        hideLoadingDialog();
//        if (mSimpleMultiStateView != null) {
//            mSimpleMultiStateView.showContent();
//        }
    }

    private void hideLoadingDialog() {
    }

    @Override
    public void showFaild() {
//        if (mSimpleMultiStateView != null) {
//            mSimpleMultiStateView.showErrorView();
//        }
    }

    @Override
    public void showNoNet() {
//        if (mSimpleMultiStateView != null) {
//            mSimpleMultiStateView.showNoNetView();
//        }
    }

    @Override
    public void onRetry() {

    }

    @Override
    public <T1> LifecycleTransformer<T1> bindToLife() {
//        return this.<T>bindToLifecycle();
        return null;
   }

    @Override
    public void onDestroy() {
//        if (mPresenter != null) {
//            mPresenter.detachView();
//        }
        super.onDestroy();
    }
}
